<?php

class FraisforfaitController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        
    }
    
    public function listerAction()
    {
        $lesFrais = new Application_Model_DbTable_Fraisforfait();
        $this->view->lesFrais = $lesFrais->fetchAll();
    }

    public function modifierAction()
    {
        $form = new Application_Form_Fraisforfait();
        $form->envoyer->setLabel('Sauvegarder');
        $this->view->form = $form;
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {
                $id = $form->getValue('id');
                $montant = $form->getValue('montant');
                $lesFrais = new Application_Model_DbTable_FraisForfait();
                $lesFrais->modifierFraisForfait($id, $montant);
                $this->_helper->redirector('index');
            } else {
                $form->populate($formData);
            }
        }else{
            $id = $this->_getParam('id', 0);
            $lesFrais = new Application_Model_DbTable_FraisForfait();
            $form->populate($lesFrais->obtenirFraisForfait($id));
        }
    }

    public function modifiervueAction()
    {
        $lesFrais = new Application_Model_DbTable_Fraisforfait();
        $this->view->lesFrais = $lesFrais->fetchAll();
    }


}



